using System;

namespace Welcome
{
	/// <summary>
	/// Summary description for MethodParams.
	/// </summary>
	class Address{
		public string name;
		public string address;
	}
	public class MethodParams
	{
		public MethodParams()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public static void Main(){
			string myChoice;
			MethodParams methodParams = new MethodParams();

			do {
				myChoice = methodParams.getChoice();
				methodParams.makeDecision(myChoice);

				Console.WriteLine("press Enter key to continue...");
				Console.ReadLine();
				Console.WriteLine();
			}while(myChoice.ToLower() != "q");
		}

		public string getChoice(){
			Console.WriteLine("My Address Book\n");

			Console.WriteLine("A - Add New Address");
			Console.WriteLine("D - Delete Address");
			Console.WriteLine("M - Modify Address");
			Console.WriteLine("V - View Addresses");
			Console.WriteLine("Q - Quit\n");

			Console.WriteLine("Choice (A,D,M,V,or Q): ");

			return Console.ReadLine();
		}

		public void makeDecision(string choice){
			Address addr = new Address();

			switch(choice.ToLower()){
				case "a":
					addr.name = "Joe";
					addr.address = "C# Station";
					this.addAddress(ref addr);
					break;
				case "d":
					addr.name = "Robert";
					this.deleteAddress(addr.name);
					break;
				case "m":
					addr.name = "Matt";
					this.modifyAddress(ref addr);
					Console.WriteLine("Name is now {0}.", addr.name);
					break;
				case "v":
					this.viewAddresses("Cheryl", "Joe", "Matt", "Robert");
					break;
				case "q":
					Console.WriteLine("Bye.");
					break;
				default:
					Console.WriteLine("{0} is not a valid choice.", choice);
					break;			
			}
		}

		void addAddress(ref Address addr){
			Console.WriteLine("Name: {0}, Address: {1} added.", addr.name, addr.address);
		}

		void deleteAddress(string name){
			Console.WriteLine("You wish to delete {0}'s address.", name);
		}

		void modifyAddress(ref Address addr){
			Console.WriteLine("Name: {0}.", addr.name); // causes error!
			addr = new Address();
			addr.name = "Joe";
			addr.address = "C# Station";
		}

		void viewAddresses(params string[] names){
			foreach(string name in names){
				Console.WriteLine("Name: {0}.", name);
			}
		}
	}
}
